package com.example.estest.controller;

import com.example.estest.watch.FileWatcher;
import jakarta.annotation.Resource;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/add")
public class FileWatcherController {

    @Autowired
    public FileWatcher fileWatcher;

    @Value("${logpath}")
    public String logpath;


    @Value("${listeningfilepath}")
    public String listeningfilepath;

    @Resource
    public RestHighLevelClient client;

    @RequestMapping("/startwatch")
    public String start() {
        fileWatcher.func(logpath,client,listeningfilepath);
        return "开始监听 当前执行时间戳为 "+System.currentTimeMillis();
    }

    @RequestMapping("/test")
    public String test() {
        return logpath;
    }
}
